package com.ssjhs.installservice;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

// For test
// adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
// adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n package_name/class_name
// adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME -n com.ssjhs.camerarec/.BootBroadcastReceiver
// adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -n com.ssjhs.camerarec/.BootBroadcastReceiver

// adb 安装 APP
//adb install -r D:\AndroidApps\CameraApp\app\build\outputs\apk\debug\app-debug.apk

// adb 启动 APP
//adb shell am start -n com.ssjhs.camerarec/.MainActivity


public final class BootBroadcastReceiver extends BroadcastReceiver {
    private static final String action_boot = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        Log.e("BootBroadcastReceiver:", action_boot);
        if (intent.getAction().equals(action_boot)) {
            Intent ootStartIntent = new Intent(context, MainActivity.class);
            ootStartIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(ootStartIntent);
        }
    }
}
